<?php
	class TutorHistoryModel extends Model {
		function TutorHistoryModel()
		{
			parent::Model();			
		}
		
		function add($data)
		{
			$dataDB = array(
               	'tutor_id' => $data['tutor_id'] ,
				'school_id' => $data['school_id'] ,
				'student_name' => $data['student_name'] ,
				'subject' => $data['subject'] ,
				'class' => $data['class'] ,
				'note' => $data['note'] ,
			    'update_by' => $this->session->userdata('username')
            );
            $this->db->set('teach_date', "str_to_date('".$data['teach_date']."', '%d/%m/%Y')", FALSE);
            $this->db->set('update_date', 'NOW()', FALSE); 
			$this->db->insert('tutor_history', $dataDB);
			return $this->db->insert_id();
		}
				
		
		function getByID($id)
		{
						$this->db->select('studied_id, tutor_id, school_name,tutor_history.school_id,subject,teach_date,student_name, class, note, tutor_history.update_date, tutor_history.update_by ');
			$this->db->from('tutor_history');
			$this->db->where(array('tutor_id' => $id));
			$this->db->join('school', 'school.school_id = tutor_history.school_id', 'left');
			$query = $this->db->get();
			return $query->result();
		}
		
	}
?>